//
// Created by mouse on 2019/12/19.
//

#ifndef NODEMCU_APP_SS_H
#define NODEMCU_APP_SS_H

#include <Arduino.h>
#include <Scheduler.h>
#include <ArduinoJson.h>
#include <Ticker.h>
#include "Utils.h"
#include "app_config.h"
#include "app_mqtt.h"
#include "app_log.h"
#include <AccelStepper.h>
#include <MultiStepper.h>

#define K_SEND_PIN D1
#define K_RECV_PIN D2

#define CMD_SET_SPEED 0x01
#define CMD_SET_POSITION 0x02
#define CMD_START_ACTION_GROUP 0x09
#define CMD_STOP_OR_RESTORE 0x0b

extern AccelStepper stepper1;

class SerialServoCmd
{
public:
    uint8_t head = 0xff;
    uint8_t cmd;
    uint8_t ch;
    uint8_t data_l;
    uint8_t data_h;
};

class StepperTask : public Task
{
private:
    NetworkTask *_networkTask;

public:
    StepperTask(NetworkTask *networkTask);

protected:
    virtual void setup() override;

    virtual void loop() override;
};

#endif //NODEMCU_APP_SS_H
